<template>
	<div class="sw_table_container">
		<el-table size="medium" :data="principalData" height="100%" class="index_table_wrapper" row-key="id" default-expand-all :tree-props="treeProps">
			<!-- <el-table-column type="index" label="序号" width="54"></el-table-column> -->
			<el-table-column prop="name" label="研究领域名称" min-width="200" show-overflow-tooltip />
			<el-table-column prop="content" label="研究领域描述" min-width="200" />
			<el-table-column prop="createName" label="创建人" width="120"></el-table-column>
			<el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
			<el-table-column label="操作" width="175" v-if="$isHasAuth(tableButton)">
				<template slot-scope="{ row }">
					<el-button size="medium" type="text" v-hasPermi="'acc82d0e7809493c9ca7521734dd277e'" @click="handleOpenDialog(row.id, 'add')">
						添加子级
					</el-button>
					<el-button size="medium" type="text" v-hasPermi="'d8a0adc113674c03a736c90d61bda417'" @click="handleOpenDialog(row.id, 'edit')">
						修改
					</el-button>
					<el-button size="medium" type="text" v-hasPermi="'4a5d5d9c95c24168898f800f7a8293b4'" @click="handleDeleteConfig(row.id)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<research-area-form v-model="formDialog" :data-id="dataId" :type="type" :handType="handType" @finish="handleUpdateData"></research-area-form>
	</div>
</template>

<script>
import researchAreaForm from './form';
import configMixins from '../configMixins';
export default {
	mixins: [configMixins],
	components: { researchAreaForm },
	data() {
		return {
			handType: null,
			treeProps: {
				children: 'children',
				hasChildren: 'hasChildren'
			}
		};
	},
	computed: {
		principalData() {
			return this.$flatToTree(this.data, 'pid');
		},
		tableButton() {
			return ['acc82d0e7809493c9ca7521734dd277e', 'd8a0adc113674c03a736c90d61bda417', '4a5d5d9c95c24168898f800f7a8293b4'];
		}
	},
	methods: {
		handleOpenDialog(id, type) {
			this.dataId = id;
			this.handType = type;
			this.formDialog = true;
		}
	}
};
</script>

<style lang="scss" scoped></style>
